using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Linq.Dynamic;
using YTS.Tools;

namespace Test.ConsoleProgram.Algorithm.Work
{
    [TestDescription("工作逻辑: 数据分页")]
    public class Test_PageIndexs : AbsBaseTestItem
    {
        public override void OnTest()
        {
            const int pageSize = 20;
            Assert.TestExe(ToPageIndexs, 19, pageSize, 1);
            Assert.TestExe(ToPageIndexs, 20, pageSize, 1);
            Assert.TestExe(ToPageIndexs, 21, pageSize, 2);
            Assert.TestExe(ToPageIndexs, 40, pageSize, 2);
            Assert.TestExe(ToPageIndexs, 41, pageSize, 3);
        }

        public int ToPageIndexs(int Sum, int pageSize)
        {
            var pageIndexs = Sum / (double)pageSize;
            pageIndexs = Math.Ceiling(pageIndexs);
            return (int)pageIndexs;
        }
    }
}
